<?php
if ( ! defined('__TYPECHO_ROOT_DIR__'))
{
    exit;
}
include 'Tyupoo.php';
$pluginOptions = $options->plugin('Tyupoo');
$typ = new Tyupoo(
				  $pluginOptions->apiKey,
				  $pluginOptions->sharedSecret,
				  $pluginOptions->authToken);
$userID = $pluginOptions->userID;
$albumList = $typ->getAlbumList($userID);
if (is_array($albumList))
{
	$albumList[] = array(
		'id' 	=> 'null',
		'title' => '默认相册',
	);
}
$albumId = empty($_GET['aid']) ? 'null' : $_GET['aid'];

if (empty($albumId) || $albumId == 'null')
{
	$photos = $typ->getNotInAlbum();
}
else
{
	$photos = $typ->getPhotos($albumId);
}
$out['albumList']    	= $albumList;
$out['albumCurrent'] 	= $albumId;
$out['photoList']    	= $photos;
$out['photoListJson']   = json_encode($photos);
$out['photoLen']		= count($photos);
$out['photoPages']  	= ceil($out['photoLen'] / 8);
$out['urlAlbum']		= Helper::url('Tyupoo/album.php');
$out['urlUpload']		= Helper::url('Tyupoo/upload.php');
include 'template/album.php';
?>